//***访问权限符的使用***


class Box {

    public String publicItem = "都能看";
    protected String protectedItem = "同包和子类能看";
    String defaultItem = "同包能看";
    private String privateItem = "只有自己能看";


    public void showPublic() {
        System.out.println(publicItem);
    }

    protected void showProtected() {
        System.out.println(protectedItem);
    }

    void showDefault() {
        System.out.println(defaultItem);
    }

    private void showPrivate() {
        System.out.println(privateItem);
    }

    public void usePrivate() {
        showPrivate();
    }
}

public class quanxian {
    public static void main(String[] args) {
        Box box = new Box();

        System.out.println("访问 public 成员:");
        System.out.println(box.publicItem);
        box.showPublic();

        System.out.println("\n访问 protected 成员:");
        box.showProtected();

        System.out.println("\n访问 default 成员:");
        box.showDefault();

        System.out.println("\n访问 private 成员:");
        box.usePrivate();
        // 下面这行代码会报错，不能直接访问 private 成员
        // System.out.println(box.privateItem);
    }
}
